<template>
  <div class="about">
    <h1>This is an about page</h1>
    <button @click="handleLink">跳转到首页</button>
  </div>
</template>
<script>
import { onMounted } from 'vue'
import { useRouter, useRoute } from 'vue-router'

export default {
  setup () {
    // 获取上一个页面传递过来的id，利用此id进行数据请求
    const router = useRouter()
    const route = useRoute()
    const handleLink = () => {
      router.push('/')
    }

    onMounted(() => {
      console.log(route.matched) // proxy 拦截
      console.log(route.params)
      console.log(router.currentRoute.value.params)
    })

    return {
      handleLink
    }
  }
}
</script>
